# Copyright 2025 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")

package(
    default_visibility = ["//visibility:private"],
    features = ["-layering_check"],
)

licenses(["notice"])

cc_library(
    name = "packets",
    srcs = [
        "h4_packet.cc",
    ],
    hdrs = [
        "public/pw_bluetooth_proxy/comms2/embossed_multibuf.h",
        "public/pw_bluetooth_proxy/comms2/h4_packet.h",
    ],
    implementation_deps = [
        "//pw_assert:check",
    ],
    strip_include_prefix = "public",
    deps = [
        "//pw_async2:dispatcher",
        "//pw_bluetooth:emboss_hci_data",
        "//pw_bluetooth:emboss_hci_h4",
        "//pw_bytes",
        "//pw_containers:intrusive_map",
        "//pw_multibuf:multibuf_v2",
        "//pw_result",
        "//pw_span:cast",
        "//pw_status",
    ],
)

pw_cc_test(
    name = "packets_test",
    srcs = [
        "h4_packet_test.cc",
    ],
    deps = [
        ":packets",
        "//pw_allocator:testing",
        "//pw_bluetooth:emboss_hci_commands",
        "//pw_bytes",
        "//pw_span",
    ],
)

cc_library(
    name = "proxy",
    srcs = [
        "l2cap_task.cc",
        "proxy.cc",
    ],
    hdrs = [
        "public/pw_bluetooth_proxy/comms2/direction.h",
        "public/pw_bluetooth_proxy/comms2/l2cap_task.h",
        "public/pw_bluetooth_proxy/comms2/proxy.h",
    ],
    implementation_deps = [
        "//pw_assert:check",
        "//pw_bluetooth:emboss_hci_commands",
        "//pw_bluetooth:emboss_hci_events",
        "//pw_log",
    ],
    strip_include_prefix = "public",
    deps = [
        ":packets",
        "//pw_allocator:chunk_pool",
        "//pw_async2:dispatcher",
        "//pw_channel:packet_channel",
        "//pw_channel:packet_proxy",
        "//pw_containers:inline_async_queue",
        "//pw_containers:vector",
    ],
)

pw_cc_test(
    name = "proxy_test",
    srcs = ["proxy_test.cc"],
    deps = [
        ":proxy",
        "//pw_allocator:testing",
        "//pw_async2:pend_func_task",
        "//pw_bytes",
        "//pw_channel:packet_channel",
        "//pw_channel:test_packet_channel",
    ],
)
